import {defineStore} from "pinia";
import axios from "axios";
import {nanoid} from "nanoid";
export const useTalkStore = defineStore('talk',{
    actions: {
      async getATalk() {
          // 连续解构赋值 + 重命名
          let {data: {content:title}} = await axios.get('https://api.uomg.com/api/rand.qinghua?format=json')
          let obj = {id: nanoid(),title}
          this.talkList.unshift(obj)
      }
    },
    state() {
        return {
            talkList: JSON.parse(localStorage.getItem('talkList') as string) || []
        }
    }
})
